package com.xzzz.common.base.enums;

import lombok.Getter;

public enum BackendServiceEnum {

    /**
     * 各个服务
     */
    BACKEND_UPMS ("backend-upms",1,"com.xzzz.backend-upms.api.xx"),
    BACKEND_AUTH ("backend-bsms",2,"com.xzzz.backend-bsms.api.xx"),
    NONE         ("none",999,""),
    ;

    /**
     * 名称
     */
    @Getter
    private final String name;

    /**
     * 排序
     */
    @Getter
    private final Integer sort;

    /**
     * 类名
     */
    @Getter
    private final String rpcClazz;


    BackendServiceEnum(String name, Integer sort, String rpcClazz) {
        this.name = name;
        this.sort = sort;
        this.rpcClazz = rpcClazz;
    }

    /**
     * 根据名字获取服务
     * @param name 服务名
     * @return 服务
     */
    public static BackendServiceEnum getByName(String name) {
        for (BackendServiceEnum value : BackendServiceEnum.values()) {
            if(value.name.equals(name.toLowerCase())){
                return value;
            }
        }
        return BackendServiceEnum.NONE;
    }
}
